# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Sergey Shatunov <me@prok.pw>

pkgname=zram-generator
pkgver=1.1.2
pkgrel=1
pkgdesc="Systemd unit generator for zram devices"
arch=("loong64" "x86_64")
url="https://github.com/systemd/zram-generator"
license=('MIT')
depends=("systemd")
makedepends=('rust' 'ruby-ronn-ng')
source=("https://github.com/systemd/zram-generator/archive/v$pkgver/$pkgname-$pkgver.tar.gz")
sha256sums=('506d47acbabffa7013bb40a1f61c6edfa758a7bd55820d06ef49c7bc83dba762')

build() {
  cd zram-generator-$pkgver
  find -name Cargo.lock -exec rm -f {} \;
  mkdir .cargo
  cat > .cargo/config.toml <<EOF
[source.crates-io]
registry = "https://gitee.com/yetist/crates.io-index"
EOF
  make CARGOFLAGS="--target-dir=target" build man
}

check() {
  cd zram-generator-$pkgver
  make CARGOFLAGS="--target-dir=target" check
}

package() {
  cd zram-generator-$pkgver

  make CARGOFLAGS="--target-dir=target" DESTDIR="$pkgdir" install
  install -Dpm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
